import { defineConfig } from 'vite'
import AutoImport from 'unplugin-auto-import/vite';
import Components from 'unplugin-vue-components/vite';
import { VantResolver } from '@vant/auto-import-resolver';
import vue from '@vitejs/plugin-vue'
import path from 'path'
// https://vite.dev/config/
export default defineConfig({
  plugins: [vue(),
     AutoImport({
      resolvers: [VantResolver()],
    }),
    Components({
      resolvers: [VantResolver()],
    })
  ],
  // 配置根路径
  resolve: {
    alias: {
      '@':path.resolve(__dirname,'./src')
    }
  },
  server: {
		// 设置代理
		proxy: {
			'/api': {
				target: 'http://localhost:3000', // 目标服务器地址
				changeOrigin: true, // 是否改变请求头中的 Origin，默认为 false
				rewrite: (path) => path.replace(/^\/api/, '/api'), // 重写路径
			},
		},
	}
})
